﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data;
using MySql.Data.MySqlClient;

namespace LibFriesland_Campina_CRM
{
    class DalGPSTracking
    {
        //Webservice
        //Them GPSTracking
        public static int addGPSTracking(BizGPSTracking pGPSTracking)
        {
            Friesland_Campina_CRM_DataContext db = new Friesland_Campina_CRM_DataContext(new MySqlConnection(Thuvien.getConnString()));
            try
            {
                GpSTracking gpsTracking = new GpSTracking();
                gpsTracking.ByNA = pGPSTracking.by_na;
                gpsTracking.Latitude = pGPSTracking.latitude;
                gpsTracking.Longitude = pGPSTracking.longitude;
                gpsTracking.DateTimePhone = pGPSTracking.datetime_phone;
                gpsTracking.DateTimeSystem = pGPSTracking.datetime_system;
                gpsTracking.IMe = pGPSTracking.ime;
                db.GpSTracking.InsertOnSubmit(gpsTracking);
                db.SubmitChanges();
                return 1;
            }
            catch(Exception ex)
            {
                return -1;
            }
        }
    }
}
